package com.web.bdo.util;

import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;

import com.web.bdo.User;
import com.web.util.obj.CountryList;

public class UserDataUtil {

	public static void setDetails(HttpServletRequest request) {
	
		User user = (User)request.getSession().getAttribute("user");
		
		if (user==null) {			
			return;
		}
		CountryList countries = new CountryList();
		String countryName = countries.getCountryById(user.getCountry());
		request.setAttribute("countryName", countryName);
		String[] sexes = {"Male", "Female"};
		String sex = sexes[user.getSex()];
		String dateCreated = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a").format(user.getDateCreated());
		request.setAttribute("user", user);
		request.setAttribute("countryName", countryName);
		request.setAttribute("sex", sex);
		request.setAttribute("dateCreated", dateCreated);		
	}
	
}
